Why doesn't setPos() work to position a dialog box?

If setPos worked, the following code should put a dialog box at the top left of the screen, but it doesn't do that and placement doesn't seem to be related to the coordinates in the setPos() call. Anyone know why?

DB dB=topMost "hello world"
setPos(dB,0,0)
label(dB,"Why?")
show dB

Actually, I did get it to work once when run after freshly starting DOORS. But then subsequent invocations kept moving the origin lower and right. Kind of defeats the purpose of the function!

Regards, Strathglass
strathglass - Wed Apr 08 07:55:17 EDT 2009

Re: Why doesn't setPos() work to position a dialog box?
dpechacek - Wed Apr 08 08:42:52 EDT 2009

You need to realize the dialog box first before you can set the position. Realizing and setting the position should be the last thing you do.

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Re: Why doesn't setPos() work to position a dialog box?
strathglass - Wed Apr 08 08:59:05 EDT 2009

dpechacek - Wed Apr 08 08:42:52 EDT 2009
You need to realize the dialog box first before you can set the position. Realizing and setting the position should be the last thing you do.

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

But how are you going to call setPos() AFTER you realize it?
OK, wait - I didn't know about the realize() function.

But it STILL does not work:
DB dB=topMost "hello world"
setPos(dB,0,0)
label(dB,"Why?")
realize dB
setPos(dB,0,0)
show dB

Although the above does not work, replacing the last 3 lines with this DOES work:
realize (dB,0,0)
show dB

So I've found a solution to my problem (thank you), but it still appears that setPos doesn't work.

Regards, Strathglass

Re: Why doesn't setPos() work to position a dialog box?
dpechacek - Wed Apr 08 09:18:42 EDT 2009

strathglass - Wed Apr 08 08:59:05 EDT 2009
But how are you going to call setPos() AFTER you realize it?
OK, wait - I didn't know about the realize() function.

But it STILL does not work:
DB dB=topMost "hello world"
setPos(dB,0,0)
label(dB,"Why?")
realize dB
setPos(dB,0,0)
show dB

Although the above does not work, replacing the last 3 lines with this DOES work:
realize (dB,0,0)
show dB

So I've found a solution to my problem (thank you), but it still appears that setPos doesn't work.

Regards, Strathglass

Interesting.
 

DB dB=topMost "hello world"
label(dB,"Why?")
realize(dB)
set(dB,0,0)
show dB

 


As you said, this works for me the first time I run it after I log into DOORS. But after I close the dialog box and run it again, it does not work as it should. However if you use numbers other than 0 for both it seems to work all the time. And yes if you use realize(DB, int, int) that seems to work all the time as well.

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

 

Re: Why doesn't setPos() work to position a dialog box?
llandale - Wed Apr 08 14:07:53 EDT 2009

Yes, you can set the original position with the realize(DB, x, y) command. Yes, you can dynamically change the position after its realized with the setPos(DB, x, y) command. This may come up in a callback or button. The following demonstrates it.

DB dB
 
void applyMoveIt(DB dbXX)
{
   int x = 0, y = 0
   getPos(dB, x, y)
   if (x == 10)
        setPos(dB, 200, 10)
   else setPos(dB, 10, 200)
}  // end applyMoveIt()
 
 
dB=topMost "hello world"
label(dB,"Why doubt me?")
apply(dB, "MoveIt", applyMoveIt)
realize(dB, 200, 200)
show dB

 


>Louie

 

Re: Why doesn't setPos() work to position a dialog box?
Tony_Goodman - Thu Apr 09 03:38:08 EDT 2009

llandale - Wed Apr 08 14:07:53 EDT 2009

Yes, you can set the original position with the realize(DB, x, y) command. Yes, you can dynamically change the position after its realized with the setPos(DB, x, y) command. This may come up in a callback or button. The following demonstrates it.

DB dB
 
void applyMoveIt(DB dbXX)
{
   int x = 0, y = 0
   getPos(dB, x, y)
   if (x == 10)
        setPos(dB, 200, 10)
   else setPos(dB, 10, 200)
}  // end applyMoveIt()
 
 
dB=topMost "hello world"
label(dB,"Why doubt me?")
apply(dB, "MoveIt", applyMoveIt)
realize(dB, 200, 200)
show dB

 


>Louie

 

Thanks Louie, I never knew that.
I wonder what use that could be?

Try this

DB db = null 
DBE dbeTimer = null
 
void doClock(DBE dbe) 
{ 
    setPos(db, random(900), random(600))
} 
 
 
db = create(dbExplorer, "Catch", styleCentered) 
 
label(db, "Catch me if you can!")
 
dbeTimer = timer(db, 1, doClock, "") 
 
realize db 
 
setCenteredSize(db, 200, 100) 
 
show db

Re: Why doesn't setPos() work to position a dialog box?
dpechacek - Thu Apr 09 08:15:40 EDT 2009

Tony_Goodman - Thu Apr 09 03:38:08 EDT 2009

Thanks Louie, I never knew that.
I wonder what use that could be?

Try this

DB db = null 
DBE dbeTimer = null
 
void doClock(DBE dbe) 
{ 
    setPos(db, random(900), random(600))
} 
 
 
db = create(dbExplorer, "Catch", styleCentered) 
 
label(db, "Catch me if you can!")
 
dbeTimer = timer(db, 1, doClock, "") 
 
realize db 
 
setCenteredSize(db, 200, 100) 
 
show db

Haha. Nice Tony. :)

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Re: Why doesn't setPos() work to position a dialog box?
llandale - Tue Apr 14 09:58:05 EDT 2009

Tony_Goodman - Thu Apr 09 03:38:08 EDT 2009

Thanks Louie, I never knew that.
I wonder what use that could be?

Try this

DB db = null 
DBE dbeTimer = null
 
void doClock(DBE dbe) 
{ 
    setPos(db, random(900), random(600))
} 
 
 
db = create(dbExplorer, "Catch", styleCentered) 
 
label(db, "Catch me if you can!")
 
dbeTimer = timer(db, 1, doClock, "") 
 
realize db 
 
setCenteredSize(db, 200, 100) 
 
show db

Use? Besides clever catch me boxes? You may want to put an end time in your code, perhaps the whole thing goes away after a minute.

Well, some years ago I came up with a silly notion of creating a status subordinate dialog box in the Library that displayed what was going on in the script when the user said go. Perhaps it would display which module the script was currently working on. I had this idea of this box figuring out where the master dialog box was and attaching itself to the bottom of it. This never worked well and I started just putting a separate status 'label' at the bottom of all my Dialogs (which, BTW, I had to initialize to 'A', and then erase it after the box was realized).

>Louie